<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tk_MaintainGeometry manual page - Tk Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tk C API</a> <small>&gt;</small> MaintGeom</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="MaintGeom.htm#M2" NAME="L443">NAME</A>
<DL><DD>Tk_MaintainGeometry, Tk_UnmaintainGeometry &mdash; maintain geometry of one window relative to another</DD></DL>
<DD><A HREF="MaintGeom.htm#M3" NAME="L444">SYNOPSIS</A>
<DL>
<DD><B>#include &lt;tk.h&gt;</B>
<DD><B>Tk_MaintainGeometry</B>(<I>window, container, x, y, width, height</I>)
<DD><B>Tk_UnmaintainGeometry</B>(<I>window, container</I>)
</DL>
<DD><A HREF="MaintGeom.htm#M4" NAME="L445">ARGUMENTS</A>
<DL class="arguments">
</DL>
<DD><A HREF="MaintGeom.htm#M5" NAME="L446">DESCRIPTION</A>
<OL class="description">
</OL>
<DD><A HREF="MaintGeom.htm#M6" NAME="L447">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
Tk_MaintainGeometry, Tk_UnmaintainGeometry &mdash; maintain geometry of one window relative to another
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tk.h&gt;</B><BR>
<B>Tk_MaintainGeometry</B>(<I>window, container, x, y, width, height</I>)<BR>
<B>Tk_UnmaintainGeometry</B>(<I>window, container</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TkLib/WindowId.htm">Tk_Window</A> <B>window</B> (in)<DD>
Window whose geometry is to be controlled.
<P><DT><A HREF="../TkLib/WindowId.htm">Tk_Window</A> <B>container</B> (in)<DD>
Window relative to which <I>window</I>'s geometry will be controlled.
<P><DT>int <B>x</B> (in)<DD>
Desired x-coordinate of <I>window</I> in <I>container</I>, measured in pixels
from the inside of <I>container</I>'s left border to the outside of
<I>window</I>'s left border.
<P><DT>int <B>y</B> (in)<DD>
Desired y-coordinate of <I>window</I> in <I>container</I>, measured in pixels
from the inside of <I>container</I>'s top border to the outside of
<I>window</I>'s top border.
<P><DT>int <B>width</B> (in)<DD>
Desired width for <I>window</I>, in pixels.
<P><DT>int <B>height</B> (in)<DD>
Desired height for <I>window</I>, in pixels.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tk_MaintainGeometry</B> and <B>Tk_UnmaintainGeometry</B> make it
easier for geometry managers to deal with windows whose containers are not
their parents.
Three problems arise if the container for a window is not its parent:
<P>
<OL class="description">
<LI value="1">
The x- and y-position of the window must be translated from the
coordinate system of the container to that of the parent before
positioning the window.
<P><LI value="2">
If the container window, or any of its ancestors up to the window's
parent, is moved, then the window must be repositioned within its
parent in order to maintain the correct position relative to the
container.
<P><LI value="3">
If the container or one of its ancestors is mapped or unmapped, then
the window must be mapped or unmapped to correspond.
<P></OL>
<P>
None of these problems is an issue if the parent and container are
the same.  For example, if the container or one of its ancestors
is unmapped, the window is automatically removed by the screen
by X.
<P>
<B>Tk_MaintainGeometry</B> deals with these problems for windows
whose containers are not their parents, as well as handling the simpler
case of windows whose container are their parents.
<B>Tk_MaintainGeometry</B> is typically called by a window manager
once it has decided where a window should be positioned relative
to its container.
<B>Tk_MaintainGeometry</B> translates the coordinates to the
coordinate system of <I>window</I>'s parent and then moves and
resizes the window appropriately.
Furthermore, it remembers the desired position and creates event
handlers to monitor the container and all of its ancestors up
to (but not including) the window's parent.
If any of these windows is moved, mapped, or unmapped,
the window will be adjusted so that it is mapped only when the
container is mapped and its geometry relative to the container
remains as specified by <I>x</I>, <I>y</I>, <I>width</I>, and
<I>height</I>.
<P>
When a window manager relinquishes control over a window, or
if it decides that it does not want the window to appear on the
screen under any conditions, it calls <B>Tk_UnmaintainGeometry</B>.
<B>Tk_UnmaintainGeometry</B> unmaps the window and cancels any
previous calls to <B>Tk_MaintainGeometry</B> for the
<I>container</I>-<I>window</I> pair, so that the window's
geometry and mapped state are no longer maintained
automatically.
<B>Tk_UnmaintainGeometry</B> need not be called by a geometry
manager if the window, the container, or any of the container's ancestors
is destroyed:  Tk will call it automatically.
<P>
If <B>Tk_MaintainGeometry</B> is called repeatedly for the same
<I>container</I>-<I>window</I> pair, the information from the most
recent call supersedes any older information.
If <B>Tk_UnmaintainGeometry</B> is called for a <I>container</I>-<I>window</I>
pair that is is not currently managed, the call has no effect.
<H3><A NAME="M6">KEYWORDS</A></H3>
<A href="../Keywords/G.htm#geometry manager">geometry manager</A>, <A href="../Keywords/M.htm#map">map</A>, <A href="../Keywords/C.htm#container">container</A>, <A href="../Keywords/P.htm#parent">parent</A>, <A href="../Keywords/P.htm#position">position</A>, <A href="../Keywords/W.htm#window">window</A>, <A href="../Keywords/U.htm#unmap">unmap</A>
<div class="copy">Copyright &copy; 1994 The Regents of the University of California.
<BR>Copyright &copy; 1994-1996 Sun Microsystems, Inc.
</div>
</BODY></HTML>
